Component({
    options: {
        styleIsolation: 'apply-shared'
    },
    behaviors: ['wx://component-export'],
    data: {
        height: 0,
    },
    lifetimes: {
        attached: function() { // 在组件实例进入页面节点树时执行
            const timeId = setTimeout(() => {
                this.getRect(this, '.fixed_button').then(res => {
                    this.setData({ height: res.height })
                })
                clearTimeout(timeId)
            }, 500)
        },
    },
    methods: {
        //获取节点位置信息
        getRect(context, selector) {
            return new Promise(function(resolve) {
                wx.createSelectorQuery()
                    .in(context)
                    .select(selector)
                    .boundingClientRect()
                    .exec(function(rect) {
                        if (rect === void 0) {
                            rect = [];
                        }
                        return resolve(rect[0]);
                    })
            })
        },
    },
    export () {
        return { height: this.data.height }
    },
})